import {useEffect, useRef} from 'react';

const useUpdate = (fn: () => void, dependency: any) => {
  const count = useRef(0);
  useEffect(() => {
    if (count.current > 0) {
      fn();
    }
    // eslint-disable-next-line
  }, [fn, ...dependency]);

  useEffect(() => {
    count.current = 1;
  }, []);
};

export {useUpdate};